package cn.easier.activity.console.repository;

import cn.easier.activity.web.entity.ActivityAdvancedSetting;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 活动高级设置 Repository
 */
@Repository
public interface ActivityAdvancedSettingRepository extends JpaRepository<ActivityAdvancedSetting, Integer> {

    /**
     * 获取某活动高级设置列表
     *
     * @param activityInfoId 活动编号
     * @return
     */
    public List<ActivityAdvancedSetting> findActivityAdvancedSettingsByActivityInfoId(Integer activityInfoId);

    /**
     * 获取某活动指定高级设置
     *
     * @param scene 适应环境
     * @param activityInfoId 活动编号
     * @return
     */
    public ActivityAdvancedSetting findActivityAdvancedSettingBySceneAndActivityInfoId(Integer scene, Integer activityInfoId);

    /**
     * 删除某活动指定奖品
     *
     * @param scene 适应环境
     * @param activityInfoId 活动编号
     * @return 影响行数
     */
    @Query(value = "DELETE FROM `activity_advanced_setting` WHERE scene = ? AND activity_info_id = ?", nativeQuery = true)
    @Modifying
    int deleteFlag(Integer scene,Integer activityInfoId);
}
